<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="./css/default.css"/>
    <link rel="stylesheet" href="./css/common.css"/>
    <link rel="stylesheet" href="./css/linggong.css"/>
    <link rel="stylesheet" href="./js/pagination/paging.css"/>
    <title>零供管理-待处理-订单管理</title>
</head>
<div class="dlg-content">
    <div class="dlg-wjd-box">
        <div class="dlg-row-7 clear-padding-left">
            <input type="text" placeholder="搜索订单、人"/>
            <button class="btn btn-default background-dark-color"><img src="./images/icon_12.png" draggable="false">
            </button>
        </div>
        <div class="dlg-row-3">
            <button class="btn btn-warning-o">
                <img src="./images/fabu.png" draggable="false">
                发布零工
            </button>

        </div>
    </div>
    <div class="dlg-row-7 clear-padding-left">
        <div class="dlg-task-lists dlg-lgsc-lists">
            <div class="dlg-box dlg-ddgl-title" id="jobTitle">

            </div>
            <ul id="dd-lists">
                <li>
                    <div class="dlg-row-5 clear-padding">
                        <div class="dlg-list-title">
                            <div class="dlg-list-imgLogo">
                                <div class="dlg-list-img">
                                    <img src="./images/mifeng.png" draggable="false"/>
                                </div>
                                <div class="dlg-cx-num">
                                    36.5
                                </div>
                            </div>
                            <div class="dlg-list-info">
                                <h3>任传伟</h3>
                                <span class="mini-size">
                                    成交3|好评2|差评1
                                </span>
                            </div>
                        </div>
                        <div>男&nbsp;24|180cm|上海-普陀</div>
                        <div>这里是个人描述16字</div>
                    </div>
                    <div class="dlg-row-5 text-right">
                        <div><h3>未开工</h3></div>
                        <div class="dlg-ddgl-time" onclick="showTimeModal()">完工时间：2017-10-12 9:00：00</div>
                        <div>
                            <button type="button" class="btn btn-warning">取消</button>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="dlg-row-5 clear-padding">
                        <div class="dlg-list-title">
                            <div class="dlg-list-imgLogo">
                                <div class="dlg-list-img">
                                    <img src="./images/mifeng.png" draggable="false"/>
                                </div>
                                <div class="dlg-cx-num">
                                    36.5
                                </div>
                            </div>
                            <div class="dlg-list-info">
                                <h3>任传伟</h3>
                                <span class="mini-size">
                                    成交3|好评2|差评1
                                </span>
                            </div>
                        </div>
                        <div>男&nbsp;24|180cm|上海-普陀</div>
                        <div>这里是个人描述16字</div>
                    </div>
                    <div class="dlg-row-5 text-right">
                        <div><h3>待付款</h3></div>
                        <div class="dlg-ddgl-time" onclick="showTimeModal()">完工时间：2017-10-12 9:00：00</div>
                        <div>
                            <span class="mini-size">共2小时&nbsp;&nbsp;合计￥20011</span>
                            <button type="button" class="btn btn-warning" id="payMoney">确认付款</button>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="dlg-row-5 clear-padding">
                        <div class="dlg-list-title">
                            <div class="dlg-list-imgLogo">
                                <div class="dlg-list-img">
                                    <img src="./images/mifeng.png" draggable="false"/>
                                </div>
                                <div class="dlg-cx-num">
                                    36.5
                                </div>
                            </div>
                            <div class="dlg-list-info">
                                <h3>任传伟</h3>
                                <span class="mini-size">
                                    成交3|好评2|差评1
                                </span>
                            </div>
                        </div>
                        <div>男&nbsp;24|180cm|上海-普陀</div>
                        <div>这里是个人描述16字</div>
                    </div>
                    <div class="dlg-row-5 text-right">
                        <div><h3>进行中</h3></div>
                        <div>接单时间：2017-10-12 9:00：00</div>
                        <div>
                            <button type="button" class="btn btn-default">取消</button>
                            <button type="button" class="btn btn-default">付款</button>
                            <button type="button" class="btn btn-default">不打卡</button>
                            <button type="button" class="btn btn-default">验收</button>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="dlg-row-5 clear-padding">
                        <div class="dlg-list-title">
                            <div class="dlg-list-imgLogo">
                                <div class="dlg-list-img">
                                    <img src="./images/mifeng.png" draggable="false"/>
                                </div>
                                <div class="dlg-cx-num">
                                    36.5
                                </div>
                            </div>
                            <div class="dlg-list-info">
                                <h3>任传伟</h3>
                                <span class="mini-size">
                                    成交3|好评2|差评1
                                </span>
                            </div>
                        </div>
                        <div>男&nbsp;24|180cm|上海-普陀</div>
                        <div>这里是个人描述16字</div>
                    </div>
                    <div class="dlg-row-5 text-right">
                        <div><h3>已完成</h3></div>
                        <div>接单时间：2017-10-12 9:00：00</div>
                        <div>
                            <button type="button" class="btn btn-warning">评价</button>
                            <button type="button" class="btn btn-default">删除</button>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="dlg-row-5 clear-padding">
                        <div class="dlg-list-title">
                            <div class="dlg-list-imgLogo">
                                <div class="dlg-list-img">
                                    <img src="./images/mifeng.png" draggable="false"/>
                                </div>
                                <div class="dlg-cx-num">
                                    36.5
                                </div>
                            </div>
                            <div class="dlg-list-info">
                                <h3>任传伟</h3>
                                <span class="mini-size">
                                    成交3|好评2|差评1
                                </span>
                            </div>
                        </div>
                        <div>男&nbsp;24|180cm|上海-普陀</div>
                        <div>这里是个人描述16字</div>
                    </div>
                    <div class="dlg-row-5 text-right">
                        <div><h3>已取消</h3></div>
                        <div>接单时间：2017-10-12 9:00：00</div>
                        <div>
                            <button type="button" class="btn btn-default">删除</button>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="dlg-row-5 clear-padding">
                        <div class="dlg-list-title">
                            <div class="dlg-list-imgLogo">
                                <div class="dlg-list-img">
                                    <img src="./images/mifeng.png" draggable="false"/>
                                </div>
                                <div class="dlg-cx-num">
                                    36.5
                                </div>
                            </div>
                            <div class="dlg-list-info">
                                <h3>任传伟</h3>
                                <span class="mini-size">
                                    成交3|好评2|差评1
                                </span>
                            </div>
                        </div>
                        <div>男&nbsp;24|180cm|上海-普陀</div>
                        <div>这里是个人描述16字</div>
                    </div>
                    <div class="dlg-row-5 text-right">
                        <div><h3>已拒绝</h3></div>
                        <div>接单时间：2017-10-12 9:00：00</div>
                        <div>
                            <button type="button" class="btn btn-default">删除</button>
                        </div>
                    </div>
                </li>

            </ul>
            <div class="dlg-page">
                <div id="pageTool" class="dlg-task-page page-common"></div>
            </div>
        </div>
    </div>
    <div class="dlg-row-3">
        <div class="dlg-task-lists dlg-info-lists">
            <div class="dlg-yq-title">
                <ol id="yq-type">
                    <li class="active">公司职员</li>
                    <li>临时雇员</li>
                    <li>附近</li>
                    <li>历史雇员</li>
                </ol>
            </div>
            <div class="dlg-yq-search">
                <input type="text" class="background-gray-color"/>
                <button class="btn background-dark-color">
                    <img src="./images/icon_12.png" draggable="false"/>
                </button>
            </div>
            <ul>
                <li>
                    <div class="dlg-row-7 clear-padding">
                        <div class="dlg-list-title">
                            <div class="dlg-list-img dlg-info-img">
                                <img src="./images/mifeng.png" draggable="false"/>
                            </div>
                            <div class="dlg-list-info dlg-info-info">
                                <div class="dlg-high-color">任传伟</div>
                                <div class="mini-size">
                                    成交3&nbsp;好评2&nbsp;差评1
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="dlg-row-3 text-right">
                        <button type="button" class="btn btn-warning mini-size">邀请</button>
                    </div>
                </li>
                <li>
                    <div class="dlg-row-7 clear-padding">
                        <div class="dlg-list-title">
                            <div class="dlg-list-img dlg-info-img">
                                <img src="./images/mifeng.png" draggable="false"/>
                            </div>
                            <div class="dlg-list-info dlg-info-info">
                                <div class="dlg-high-color">任传伟</div>
                                <div class="mini-size">
                                    成交3&nbsp;好评2&nbsp;差评1
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="dlg-row-3 text-right">
                        <button type="button" class="btn mini-size" disabled="disabled">已邀请</button>
                    </div>
                </li>
                <li>
                    <div class="dlg-row-7 clear-padding">
                        <div class="dlg-list-title">
                            <div class="dlg-list-img dlg-info-img">
                                <img src="./images/mifeng.png" draggable="false"/>
                            </div>
                            <div class="dlg-list-info dlg-info-info">
                                <div class="dlg-high-color">任传伟</div>
                                <div class="mini-size">
                                    成交3&nbsp;好评2&nbsp;差评1
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="dlg-row-3 text-right">
                        <button type="button" class="btn mini-size">已拒绝</button>
                    </div>
                </li>
                <li>
                    <div class="dlg-row-7 clear-padding">
                        <div class="dlg-list-title">
                            <div class="dlg-list-img dlg-info-img">
                                <img src="./images/mifeng.png" draggable="false"/>
                            </div>
                            <div class="dlg-list-info dlg-info-info">
                                <div class="dlg-high-color">任传伟</div>
                                <div class="mini-size">
                                    成交3&nbsp;好评2&nbsp;差评1
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="dlg-row-3 text-right">
                        <button type="button" class="btn btn-warning mini-size">邀请</button>
                    </div>
                </li>
            </ul>
            <div id="pageTool1" class="dlg-task-page page-small"></div>
        </div>
    </div>
</div>
<div id="pay_modal" class="modal_bg_ground">
    <div class="modal_tan" style="width:520px;">
        <span class="close">x</span>
        <div class="dlg-payment-modal" id="querenzhifu">

        </div>
    </div>
</div>
<div id="hesuan_modal" class="modal_bg_ground">
    <div class="modal_tan" style="width:320px;">
        <span class="close">x</span>
        <div class="dlg-common-modal">
            <h3 class="text-center">确定验收件数</h3>
            <div>
                <label>验收件数：</label><span id="jian">5件</span>
            </div>
            <div>
                <label>通过</label><input type="number" id="adoptNumber" placeholder="0" value="0"><span>件</span>
            </div>
            <div>
                <label>不通过</label><input type="number" id="noAdoptNumber" placeholder="0" value="0"><span>件</span>
            </div>
            <div>
                <label>不通过原因</label><textarea id="acceptdesc" style="width: 164px" maxlength="30"></textarea>
            </div>
            <div>
                <label></label>
                <button type="button" class="btn btn-default" onclick="cancelZF()">取消</button>&nbsp;
                <button type="button" class="btn btn-warning-o" onclick="querenHs()">下一步</button>

            </div>

        </div>
    </div>
</div>
<div id="check_number_modal" class="modal_bg_ground">
    <div class="modal_tan" style="width:320px;">
        <span class="close">x</span>
        <div class="dlg-common-modal">
            <h3 class="text-center">确定核算金额</h3>
            <div>
                <label>核算</label><span class="dlg-red-color" id="amount">5元</span>
            </div>
            <div>
                <label>小费</label><input id="zf-fee" type="number" placeholder="0">&nbsp;<span>元</span>
            </div>
            <div>
                <label></label>
                <button type="button" class="btn btn-default" onclick="cancelCheckNumber()">取消</button>&nbsp;
                <button type="button" class="btn btn-warning-o" onclick="querenwancheng()">确认</button>
            </div>
        </div>
    </div>
</div>
<input type="hidden" id="orderid"/>
<input type="hidden" id="employer_id"/>
<input type="hidden" id="changestyle" value="1">
<input type="hidden" id="day_date">
<input type="hidden" id="order_id">
<script src="js/pagination/paging.js"></script>
<script src="js/public.js"></script>
<script src="./js/md5.js" type="text/javascript"></script>
<script>

    var jobId = sessionStorage.getItem("jobId");

    $("#ddgl-type li,#yq-type li").click(function () {
        addActive(this);
    })
    $("#ddgl-type li").click(function () {
        var index = $(this).index();
        $("#dd-lists li").hide();
        for (var i = 0; i < $("#dd-lists li").length; i++) {
            var obj = $("#dd-lists li").eq(i).find(".text-right h3").html();
            switch (index) {
                case 1:
                    if (obj.indexOf('取消') == -1 && obj.indexOf('拒绝') == -1 && obj.indexOf('完成') == -1) {
                        $("#dd-lists li").eq(i).show();
                    }
                    break;
                case 2:
                    if (obj.indexOf('完成') > -1) {
                        $("#dd-lists li").eq(i).show();
                    }
                    break;
                case 3:
                    if (obj.indexOf('取消') > -1 || obj.indexOf('拒绝') > -1) {
                        $("#dd-lists li").eq(i).show();
                    }
                    break;
                default:
                    $("#dd-lists li").show();
                    break
            }
        }
    })
    $(function () {
        orderData(0, 0);
        $("#payMoney").click(function () {
            showPaymentModal()
        })
    })

    function showCalendar(obj, valueArr) {
        $(obj).calendar({
            'left': $(obj).offset().left,
            'top': $(obj).offset().top - 30,
            ifSwitch: true,
            hoverDate: true,
            status: valueArr
        });
    }

    //单次单选弹框
    function showPaymentModal(orderId) {
        $("#pay_modal").show();
        $.ajax({
            url: url + '/account/' + userid + '/corder',
            type: 'post',
            dataType: 'json',
            data: "clienttype=1" +
            "&business=order" +
            "&ids=" + orderId +
            "&bconfirm=0"+
            "&userid=" + userid +
            "&access_token=" + access_token,
            //timeout: '1000',
            cache: 'false',
            success: function (jsData) {
                console.log("订单账单信息", jsData)
                var result = "";

                if (jsData.body.msg == "无可支付订单") {
                    $("#pay_modal").hide();
                    alert("请去钱包结算")
                } else {
                    var amount = jsData.body.data.totalfee + Number(jsData.body.data.paltincome);
                    console.log("支付总金额",amount)
                    result += "<h3 class=\"text-center add-padding-15\">确认付款</h3>";
                    result += "<div class=\"title\">账单明细</div>";
                    result += "<div class=\"dlg-payment-account\">";
//                    result += "     <div>";
//                    result += "         <label>报酬</label>";
//                    result += "         <span>600.00元</span>";
//                    result += "     </div>";
//                    result += "     <div>";
//                    result += "         <label>小费</label>";
//                    result += "         <span>10.00元</span>";
//                    result += "     </div>";
//                    result += "     <div>";
//                    result += "         <label>扣款</label>";
//                    result += "         <span>0元</span>";
//                    result += "     </div>";
//                    result += "     <div>";
//                    result += "         <label>平台服务费</label>";
//                    result += "         <span>24.00元</span>";
//                    result += "     </div>";
                    result += "     <div>";
                    result += "         <label>总金额</label>";
                    result += "         <span>"+amount+"元</span>";
                    result += "     </div>";
                    result += "</div>";
                    result += "<div class=\"title\">选择付款方式</div>";
                    result += "<ul id=\"PaymentType\">";
                    result += "     <li class=\"active\" data-index='1' onclick='changeStyle(this)'>余额</li>";
                    result += "     <li data-index='2' onclick='changeStyle(this)'>微信</li>";
                    result += "     <li data-index='3' onclick='changeStyle(this)'>支付宝</li>";
                    //result += "     <li data-index='4'>一网通银行卡支付</li>";
                    result += "</ul>";
                    result += "<div id='yue'>";
                    result += "     <div id=\"showSum\" class=\"dlg-red-color\">可用余额1500.00元</div>";
                    result += "     <div class=\"title\">请输入支付密码</div>";
                    result += "     <div id='pwd'>";
                    result += "         <input type=\"password\" maxlength=\"1\" oninput=\"paymentJump(this)\"/>";
                    result += "         <input type=\"password\" maxlength=\"1\" oninput=\"paymentJump(this)\"/>";
                    result += "         <input type=\"password\" maxlength=\"1\" oninput=\"paymentJump(this)\"/>";
                    result += "         <input type=\"password\" maxlength=\"1\" oninput=\"paymentJump(this)\"/>";
                    result += "         <input type=\"password\" maxlength=\"1\" oninput=\"paymentJump(this)\"/>";
                    result += "         <input type=\"password\" maxlength=\"1\" oninput=\"paymentJump(this)\"/>";
                    result += "     </div>";
                    result += "     <div class=\"text-center add-padding-15\">";
                    result += "          <button type=\"button\" class=\"btn btn-warning\" onclick=\"cancelPaymentModal('" + jsData.body.data.achid + "','" + jsData.body.data.paymentid + "')\">立即支付</button>&nbsp;&nbsp;";
                    result += "          <button type=\"button\" class=\"btn btn-default\" onclick=\"cancelPaymentModal()\">取消</button>";
                    result += "     </div>";
                    result += "</div>";
                    result += "<div id='weixin' style='display: none;'>";
                    result += "</div>";
                    result += "<div id='zhifubao' style='display: none;'>";
                    result += "</div>";

                    $("#querenzhifu").html(result);
                }
            }
        })
    }

    function changeStyle(obj) {
        $("#showSum").hide();
        $("#changestyle").val($(obj).attr("data-index"));
        switch ($(obj).attr("data-index")) {
            case "1":
                $("#weixin").hide();
                $("#zhifubao").hide();
                $("#yue").show();
                $("#showSum").show();
                break;
            case "2":
                $("#yue").hide();
                $("#zhifubao").hide();
                $("#weixin").show();
                break;
            case "3":
                $("#yue").hide();
                $("#weixin").hide();
                $("#zhifubao").show();
                break;
        }
        $(obj).siblings().removeClass("active");
        $(obj).addClass("active");
    }

    var inputs = "";

    function cancelPaymentModal(achid, orderid) {
        console.log("achid", achid)
        console.log("orderid", orderid)
        if (inputs.length == 0) {
            alert("请输入密码")
            $("#pay_modal").show();
        }

        if ($("#changestyle").val() == "1") {
            var password = hex_md5(inputs);
            $.ajax({
                url: url + '/account/' + userid + '/' + orderid + '/balance',
                type: 'post',
                dataType: 'json',
                data: "clienttype=1" +
                "&achid=" + achid +
                "&paypwd="+password+
                "&userid=" + userid +
                "&access_token=" + access_token,
                //timeout: '1000',
                cache: 'false',
                success: function (jsData) {
                    console.log("支付完成", jsData)
                    if (jsData.body.msg == "支付成功-等待结算") {
                        alert("支付成功")
                    }
                }
            })
        }
    }

    function paymentJump(obj) {
        $(obj).focus().css("border-color", "#ddd");
        if (/\d/.test($(obj).val())) {
            if (parseInt($(obj).val())) {
                $(obj).next().focus();
                inputs += $(obj).val();
            } else {
                $(obj).prev().focus();
            }
        } else {
            $(obj).val("").focus().css("border-color", "red");
            return false;
        }
    }

    function todoPageSize(pageSize, total, status) {
        $('#pageTask').Paging({
            pageSize: pageSize,
            count: total,
            callback: function (page, size, count) {

                orderData(page - 1, status);
            }
        });
    }

    function todoPageSizeTongyi(pageSize, total, status) {
        $('#pageTask').Paging({
            pageSize: pageSize,
            count: total,
            callback: function (page, size, count) {

                dataOrder(page - 1, status);
            }
        });
    }

    //全部 、进行中、已完成
    function orderData(status, pagenum) {

        $.ajax({
            url: url + '/order/job/' + jobId,
            type: 'post',
            dataType: 'json',
            data: "size=10" +
            "&userid=" + userid +
            "&status=" + status +
            "&clienttype=1" +
            //"&eeorer=er" +
            "&pageindex=" + pagenum +
            "&access_token=" + access_token,
            //timeout: '1000',
            cache: 'false',
            success: function (jsData) {
                console.log("全部订单接口", jsData)

                var result = "";
                var resultTile = "";

                resultTile += "<div class=\"dlg-task-title\">";
                resultTile += "     <div class=\"dlg-row-5 clear-padding\">";
                //resultTile += "         <div>"+jsData.body.data.list[0].job_info.task_title+"</div>";
                resultTile += "         <div>任务名称</div>";
                resultTile += "         <div class=\"mini-size dlg-gr\">工作时间：10.2-10.4 9:00-18:00</div>";
                resultTile += "     </div>";
                resultTile += "     <div class=\"dlg-row-5 text-right\">";
                resultTile += "         <div>";
                resultTile += "             <span class=\"dlg-red-color\">50元</span><span class=\"mini-size\">/小时</span>";
                resultTile += "         </div>";
                resultTile += "     </div>";
                resultTile += "</div>";

                resultTile += "<div class=\"dlg-ddgl-tabs\">";
                resultTile += "     <ol id=\"ddgl-type\">";
                resultTile += "         <li class=\"active\" onclick=\"orderData(0,0)\">全部(9)</li>";
                resultTile += "         <li onclick=\"daitongyi(0)\">待同意(7)</li>";
                resultTile += "         <li onclick=\"orderData(30,0)\">进行中(7)</li>";
                resultTile += "         <li onclick=\"orderData(90,0)\">已完成(1)</li>";
                resultTile += "         <li>已取消(1)</li>";
                resultTile += "     </ol>";
                resultTile += "</div>";

                if (jsData.body.data.list.length > 0) {

                    for (var i = 0; i < jsData.body.data.list.length; i++) {
                        result += "<li>";
                        result += "     <div class=\"dlg-row-5 clear-padding\">";
                        result += "         <div class=\"dlg-list-title\">";
                        result += "             <div class=\"dlg-list-imgLogo\">";
                        result += "                 <div class=\"dlg-list-img\">";
                        result += "                     <img src=\"./images/mifeng.png\" draggable=\"false\"/>";
                        result += "                 </div>";
                        result += "                 <div class=\"dlg-cx-num\">";
                        result += "                     36.5";
                        result += "                 </div>";
                        result += "             </div>";
                        result += "             <div class=\"dlg-list-info\">";
                        result += "                 <h3>" + jsData.body.data.list[i].employee_name + "</h3>";
                        result += "                 <span class=\"mini-size\">";
                        result += "                     成交3|好评2|差评1";
                        result += "                 </span>";
                        result += "             </div>";
                        result += "         </div>";
                        result += "         <div>";
                        if (jsData.body.data.list[0].job_info.sex == 1) {
                            result += "男&nbsp;";
                        } else if (jsData.body.data.list[0].job_info.sex == 2) {
                            result += "女&nbsp;";
                        } else if (jsData.body.data.list[0].job_info.sex == 3) {
                            result += "不限&nbsp;";
                        }
                        result += "         24|180cm|上海-普陀</div>";
                        result += "         <div>" + jsData.body.data.list[0].job_info.task_description + "</div>";
                        result += "     </div>";

                        if (jsData.body.data.list[i].job_info.cost_accounting_type == "1" || jsData.body.data.list[i].job_info.cost_accounting_type == "3") {

                            result += "<div class=\"dlg-row-5 text-right\">";
                            result += "     <div><h3>" + jsData.body.data.list[i].status_text + "</h3></div>";
                            result += "     <div class=\"dlg-ddgl-time\" onclick=\"time(this,'" + jsData.body.data.list[i].id + "','" + jsData.body.data.list[i].job_info.start_date + "','" + jsData.body.data.list[i].job_info.end_date + "','" + jsData.body.data.list[i].employer_id + "')\">接单时间：" + jsData.body.data.list[0].create_time + "</div>";
                            result += "     <div>";
                            for (var j = 0; j < jsData.body.data.list[i].buttons.length; j++) {

                                if (jsData.body.data.list[i].buttons[j].operateStatusText == "取消") {
                                    result += "<button type=\"button\" class=\"btn btn-default\" onclick=\"tongyi('" + jsData.body.data.list[i].employer_id + "','" + jsData.body.data.list[i].employee_id + "')\">" + jsData.body.data.list[i].buttons[j].operateStatusText + "</button>&nbsp;&nbsp;";
                                } else if (jsData.body.data.list[i].buttons[j].operateStatusText == "支付") {
                                    result += "<button type=\"button\" class=\"btn btn-default\" onclick=\"showPaymentModal('" + jsData.body.data.list[i].id + "')\">" + jsData.body.data.list[i].buttons[j].operateStatusText + "</button>&nbsp;&nbsp;";
                                } else if (jsData.body.data.list[i].buttons[j].operateStatusText == "补卡") {
                                    result += "<button type=\"button\" class=\"btn btn-default\" onclick=\"showPaymentModal('" + jsData.body.data.list[i].id + "')\">" + jsData.body.data.list[i].buttons[j].operateStatusText + "</button>&nbsp;&nbsp;";
                                } else if (jsData.body.data.list[i].buttons[j].operateStatusText == "结算") {
                                    result += "<button type=\"button\" class=\"btn btn-default\" onclick=\"showPaymentModal('" + jsData.body.data.list[i].id + "')\">" + jsData.body.data.list[i].buttons[j].operateStatusText + "</button>&nbsp;&nbsp;";
                                } else if (jsData.body.data.list[i].buttons[j].operateStatusText == "取消订单") {
                                    result += "<button type=\"button\" class=\"btn btn-default\" onclick=\"quxiao('"+jsData.body.data.list[i].id+"')\">" + jsData.body.data.list[i].buttons[j].operateStatusText + "</button>&nbsp;&nbsp;";
                                } else if (jsData.body.data.list[i].buttons[j].operateStatusText == "补打卡") {
                                    result += "<button type=\"button\" class=\"btn btn-default\" >" + jsData.body.data.list[i].buttons[j].operateStatusText + "</button>&nbsp;&nbsp;";
                                } else if (jsData.body.data.list[i].buttons[j].operateStatusText == "下架") {
                                    result += "<button type=\"button\" class=\"btn btn-default\" >" + jsData.body.data.list[i].buttons[j].operateStatusText + "</button>&nbsp;&nbsp;";
                                } else if (jsData.body.data.list[i].buttons[j].operateStatusText == "修改") {
                                    result += "<button type=\"button\" class=\"btn btn-default\" >" + jsData.body.data.list[i].buttons[j].operateStatusText + "</button>&nbsp;&nbsp;";
                                }
                            }
                            result += "      </div>";
                            result += "</div>";
                        } else if (jsData.body.data.list[i].job_info.cost_accounting_type == "2") {
                            result += "<div class=\"dlg-row-5 text-right\">";
                            result += "     <div><h3>"+jsData.body.data.list[i].status_text+"</h3></div>";

                            var start_date = jsData.body.data.list[i].start_date.slice(5);
                            var end_date = jsData.body.data.list[i].end_date.slice(5);

                            result += "     <div class=\"dlg-ddgl-time\" onclick=\"time(this,'" + jsData.body.data.list[i].id + "','" + jsData.body.data.list[i].job_info.start_date + "','" + jsData.body.data.list[i].job_info.end_date + "','" + jsData.body.data.list[i].employer_id + "')\">接单时间："+start_date.replace("-",".")+"- "+end_date.replace("-",".")+"</div>";
                            result += "     <div>";
                            result += "         <span class=\"mini-size\">共2小时&nbsp;&nbsp;合计￥200</span>";
                            for (var j = 0; j < jsData.body.data.list[i].buttons.length; j++) {
                                if (jsData.body.data.list[i].buttons[j].operateStatusText == "取消") {
                                    result += "<button type=\"button\" class=\"btn btn-default\" onclick=\"tongyi('" + jsData.body.data.list[i].employer_id + "','" + jsData.body.data.list[i].employee_id + "')\">" + jsData.body.data.list[i].buttons[j].operateStatusText + "</button>&nbsp;&nbsp;";
                                } else if (jsData.body.data.list[i].buttons[j].operateStatusText == "支付") {
                                    result += "<button type=\"button\" class=\"btn btn-default\" onclick=\"showPaymentModal('" + jsData.body.data.list[i].id + "')\">" + jsData.body.data.list[i].buttons[j].operateStatusText + "</button>&nbsp;&nbsp;";
                                } else if (jsData.body.data.list[i].buttons[j].operateStatusText == "补卡") {
                                    result += "<button type=\"button\" class=\"btn btn-default\">" + jsData.body.data.list[i].buttons[j].operateStatusText + "</button>&nbsp;&nbsp;";
                                } else if (jsData.body.data.list[i].buttons[j].operateStatusText == "结算") {
                                    result += "<button type=\"button\" class=\"btn btn-warning\" id=\"payMoney\" onclick=\"showPaymentModal('" + jsData.body.data.list[i].id + "')\">" + jsData.body.data.list[i].buttons[j].operateStatusText + "</button>&nbsp;&nbsp;";
                                } else if (jsData.body.data.list[i].buttons[j].operateStatusText == "取消订单") {
                                    result += "<button type=\"button\" class=\"btn btn-warning\" onclick=\"quxiao('"+jsData.body.data.list[i].id+"')\">" + jsData.body.data.list[i].buttons[j].operateStatusText + "</button>&nbsp;&nbsp;";
                                }else if (jsData.body.data.list[i].buttons[j].operateStatusText == "确认金额") {
                                    result += "<button type=\"button\" class=\"btn btn-warning\" onclick=\"time(this,'" + jsData.body.data.list[i].id + "','" + jsData.body.data.list[i].job_info.start_date + "','" + jsData.body.data.list[i].job_info.end_date + "','" + jsData.body.data.list[i].employer_id + "')\">" + jsData.body.data.list[i].buttons[j].operateStatusText + "</button>&nbsp;&nbsp;";
                                }
                            }
                            result += "     </div>";
                            result += "</div>";
                        }
                        result += "</li>";
                    }
                } else {
                    result += "<li>";
                    result += " <div class=\"dlg-row add-padding-15\">";
                    result += "     <h3 class='font-16 text-center' style='color: red;'>";
                    result += "         <img class='dlg-no-list-img' src='./images/no-list.png'/>";
                    result += "     </h3>";
                    result += " </div>";
                    result += "</li>";
                }

                $("#jobTitle").html(resultTile);
                $("#dd-lists").html(result);

                todoPageSize(9, jsData.body.data.total);
            }
        })
    }

    //待同意接口
    function daitongyi(pagenum) {

        $.ajax({
            url: url + '/order/job/message/list',
            type: 'post',
            dataType: 'json',
            data: "&userid=" + userid +
            "&pageindex=" + pagenum +
            "&jobid=" + jobId +
            "&size=10" +
            "&clienttype=1" +
            "&messagetype=OPER_ORDER_APPLY_CODE" +
            "&access_token=" + access_token,
            timeout: '1000',
            cache: 'false',
            success: function (jsData) {
                console.log("待同意", jsData)

                var result = "";
                var resultTile = "";
                if (jsData.body.data.list.length > 0) {
                    resultTile += "<div class=\"dlg-task-title\">";
                    resultTile += "     <div class=\"dlg-row-5 clear-padding\">";
                    //resultTile += "         <div>"+jsData.body.data.list[0].content.jobname+"</div>";
                    resultTile += "         <div>待同意零工名称</div>";
                    resultTile += "         <div class=\"mini-size dlg-gr\">工作时间：10.2-10.4 9:00-18:00</div>";
                    resultTile += "     </div>";
                    resultTile += "     <div class=\"dlg-row-5 text-right\">";
                    resultTile += "         <div>";
                    resultTile += "             <span class=\"dlg-red-color\">50元</span><span class=\"mini-size\">/小时</span>";
                    resultTile += "         </div>";
                    resultTile += "     </div>";
                    resultTile += "</div>";

                    resultTile += "<div class=\"dlg-ddgl-tabs\">";
                    resultTile += "     <ol id=\"ddgl-type\">";
                    resultTile += "         <li class=\"active\" onclick=\"orderData(0)\">全部(9)</li>";
                    resultTile += "         <li onclick=\"daitongyi(0)\">待同意(7)</li>";
                    resultTile += "         <li onclick=\"orderData(22,0)\">进行中(7)</li>";
                    resultTile += "         <li onclick=\"orderData(40,0)\">已完成(1)</li>";
                    resultTile += "         <li>已取消(1)</li>";
                    resultTile += "     </ol>";
                    resultTile += "</div>";

                    for (var i = 0; i < jsData.body.data.list.length; i++) {
                        result += "<li>";
                        result += "     <div class=\"dlg-row-5 clear-padding\">";
                        result += "         <div class=\"dlg-list-title\">";
                        result += "             <div class=\"dlg-list-imgLogo\">";
                        result += "                 <div class=\"dlg-list-img\">";
                        result += "                     <img src=\"./images/mifeng.png\" draggable=\"false\"/>";
                        result += "                 </div>";
                        result += "                 <div class=\"dlg-cx-num\">";
                        result += "                     36.5";
                        result += "                 </div>";
                        result += "             </div>";
                        result += "             <div class=\"dlg-list-info\">";
                        result += "                 <h3>" + jsData.body.data.list[i].content.employeename + "</h3>";
                        result += "                 <span class=\"mini-size\">";
                        result += "                     成交3|好评2|差评1";
                        result += "                 </span>";
                        result += "             </div>";
                        result += "         </div>";
                        result += "         <div>男&nbsp;24|180cm|上海-普陀</div>";
                        result += "         <div>这里是个人描述16字</div>";
                        result += "     </div>";
                        result += "     <div class=\"dlg-row-5 text-right\">";
                        result += "         <div><h3>" + jsData.body.data.list[i].status_text + "</h3></div>";
                        result += "         <div class=\"dlg-ddgl-time\" onclick='showCalendar(this)' >接单时间：2017-10-12 9:00:00</div>";
                        result += "         <div>";
                        for (var j = 0; j < jsData.body.data.list[i].buttons.length; j++) {
                            if (jsData.body.data.list[i].buttons[j].operateStatusCode == "agree") {
                                result += "<button type=\"button\" class=\"btn btn-default\" onclick=\"tongyi('" + jsData.body.data.list[i].id + "')\">" + jsData.body.data.list[i].buttons[j].operateStatusText + "</button>&nbsp;&nbsp;";
                            } else if (jsData.body.data.list[i].buttons[j].operateStatusCode == "refuse") {
                                result += "<button type=\"button\" class=\"btn btn-default\">" + jsData.body.data.list[i].buttons[j].operateStatusText + "</button>&nbsp;&nbsp;";
                            }
                        }
                        result += "         </div>";
                        result += "     </div>";
                        result += "</li>";
                    }
                } else {
                    result += "<li>";
                    result += " <div class=\"dlg-row add-padding-15\">";
                    result += "     <h3 class='font-16 text-center' style='color: red;'>";
                    result += "         <img class='dlg-no-list-img' src='./images/no-list.png'/>";
                    result += "     </h3>";
                    result += " </div>";
                    result += "</li>";
                }

                $("#jobTitle").html(resultTile);
                $("#dd-lists").html(result);

                todoPageSize(9, jsData.body.data.total);
            }
        })
    }

    function tongyi(messageid) {

        $.ajax({
            url: url + '/order/job/message/agree',
            type: 'post',
            dataType: 'json',
            data: "userid=" + userid +
            "&messageid=" + messageid +
            "&clienttype=1" +
            "&access_token=" + access_token,
            //timeout: '1000',
            cache: 'false',
            success: function (jsData) {
                console.log("同意接口", jsData)
                orderData(0, 0);
            }
        })
    }

    /**
     * 点击日期查询列表
     */
    function time(that, orderid, startdate, enddate, employer_id) {
        $("#orderid").val(orderid);
        $("#employer_id").val(employer_id);


        $.ajax({
            url: url + '/order/' + orderid + '/children',
            type: 'post',
            dataType: 'json',
            data: "userid=" + employer_id +
                "&clienttype=1" +
                "&startdate=" + startdate +
                "&enddate=" + enddate +
                "&access_token=" + access_token,
            timeout: '1000',
            cache: 'false',
            success: function (jsData) {
                console.log("日期插件", jsData)
                var valueArr = "[";
                var result = "";

                if (jsData.body.data.list.length > 0) {
                    for (var i = 0; i < jsData.body.data.list.length; i++) {
                        $("#amount").html(jsData.body.data.list[i].amount+"元");
                        if (jsData.body.data.list[i].cost_accounting_type == "1") {
                            $("#jian").html(jsData.body.data.list[i].piecework.submission_count+"/时");
                        }else if (jsData.body.data.list[i].cost_accounting_type == "2") {
                            $("#jian").html(jsData.body.data.list[i].piecework.submission_count+"/件");
                        }else {
                            $("#jian").html(jsData.body.data.list[i].piecework.submission_count+"/件");
                        }
                        var date = jsData.body.data.list[i].day_date.replace(/-/g, "");
                        valueArr += '{"workDate":"' + date + '",' +
                            '"price":"' + jsData.body.data.list[i].amount + '",' +
                            '"startTime":"' + jsData.body.data.list[i].attendance.start_date_time + '",' +
                            '"endTime":"' + jsData.body.data.list[i].attendance.end_date_time + '",' +
                            '"status_text":"' + jsData.body.data.list[i].status_text + '",' +
                            '"status":"' + jsData.body.data.list[i].status + '"},';
                    }
                    valueArr = valueArr.substring(0, valueArr.length - 1);
                    valueArr += "]";
                    showCalendar(that, JSON.parse(valueArr));
                } else {
                    result += "<li>";
                    result += " <div class=\"dlg-row add-padding-15\">";
                    result += "     <h3 class='font-16 text-center' style='color: red;'>";
                    result += "         <img class='dlg-no-list-img' src='./images/no-list.png'/>";
                    result += "     </h3>";
                    result += " </div>";
                    result += "</li>";
                }
            }
        })
    }

    /**
     * 雇主给雇员补卡
     * @param day_date
     * @param order_id
     * @param job_id
     */
    function buka() {

    }

    /**
     * 雇主取消订单
     * @param orderId
     */
    function quxiao(orderId){
        $.ajax({
            url: url + '/order/' + orderId + '/cancel',
            type: 'post',
            dataType: 'json',
            data: "userid=" + userid +
                "&clienttype=1" +
                "&access_token=" + access_token,
            timeout: '1000',
            cache: 'false',
            success: function (jsData) {
                console.log("取消订单", jsData)
                if (jsData.body.msg == "成功") {
                    jumpChildrenPage("linggongguanli/jinxingzhong_dingdanguanli.html?jobId=" + jobId + "", "rightPart")
                }
            }
        })
    }

    /**
     * 确定完成跳转
     */
    function querenwancheng() {

        var acceptcount = $("#adoptNumber").val();
        var acceptdesc = $("#acceptdesc").val();
        var reward = $("#zf-fee").val();
        var order_id = $("#order_id").val();
        var day_date = $("#day_date").val();

        $.ajax({
            url: url + '/order/' + order_id + '/child/confirm',
            type: 'post',
            dataType: 'json',
            data: "userid=" + userid +
                "&clienttype=1" +
                "&daydate=" + day_date +
                "&acceptcount="+acceptcount+
                "&acceptdesc="+acceptdesc+
                "&reward="+reward+
                "&access_token=" + access_token,
            timeout: '1000',
            cache: 'false',
            success: function (jsData) {
                console.log("确认付款", jsData)
                if (jsData.body.msg == "成功") {
                    jumpChildrenPage("linggongguanli/jinxingzhong_dingdanguanli.html?jobId=" + jobId + "", "rightPart")
                }
            }
        })
    }

    function cancelZF() {
        $("#zf-fee").val("");
        $("#hesuan_modal").hide();
    }

    function querenHs() {
        $("#hesuan_modal").hide();
        $("#check_number_modal").show();
    }
    function cancelCheckNumber() {
        $("#check_number_modal").hide();
    }
    function querenCheckNumber() {
        $("#check_number_modal").hide();
    }
</script>